package com.xhh.microfin.dispatch.service.process.impl;

import com.xhh.microfin.dispatch.model.entity.ProcessVar;
import com.xhh.microfin.dispatch.model.entity.TaskVar;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 003035
 * @Date: 2019/1/22
 */
@Data
public class Var {

    private String varCode;

    private String value;

    private Integer ctime;

    public Var() {
    }

    public Var(String varCode, String value, Integer ctime) {
        this.varCode = varCode;
        this.value = value;
        this.ctime = ctime;
    }

    public static List<Var> getVarFromProcessVar(List<ProcessVar> processVars) {

        List<Var> vars = new ArrayList<>();
        processVars.forEach(processVar -> {
            vars.add(new Var(processVar.getVarCode(),processVar.getValue(),processVar.getCtime()));
        });
        return vars;
    }

    public static List<Var> getVarFromTaskVar(List<TaskVar> taskVars) {

        List<Var> vars = new ArrayList<>();
        taskVars.forEach(taskVar -> {
            vars.add(new Var(taskVar.getVarCode(),taskVar.getValue(),taskVar.getCtime()));
        });
        return vars;
    }
}
